<template>
	<div class="tmpl">
		<!-- 1.0 轮播 -->	
		<silder class="silder" :swipeList="swipeList"></silder>

		<!-- 2.0 购买操作区域 -->
		<div class="opt">
			<inputnumber v-on:sendcount="getcount"></inputnumber>

			<mt-button type="danger" @click="addShopCar">加入购物车</mt-button>
		</div>

		<!-- 3.0 商品参数区域 -->

		<!-- 4.0 图文介绍和商品评论 -->

	</div>
</template>

<script>
// 1.0 导入轮播组件
import silder from '../subcom/silder.vue';
import common from '../../kits/common.js';
import inputnumber from '../subcom/inputnumber.vue';
	export default{
		data(){
			return {
				goodsid:0,
				count:1, //接收inputNumber.vue组件传入的值
				swipeList:[]
			}
		},
		methods:{
			// 1.0 获取轮播组件需要的图片
			getswipelist(){
				var url = common.apiDomain+'/api/getthumimages/'+this.goodsid;

				this.$http.get(url).then(res=>{
					res.body.message.forEach(item=>{
						item.img =common.imgDomain +item.src;
						item.url=""
					});

					this.swipeList = res.body.message;
				});
			},
			// 2.0 获取inputNumber组件发送过来的count值
			getcount(count){
				this.count = count;
			},
			// 3.0 加入购物车方法
			addShopCar(){
				// 1.0 获取到购买的数量（来源于inputNumber组件）
				alert(this.count);
			}
		},
		created(){
			this.goodsid = this.$route.params.goodsid;
			
			// 调用数据获取工作
			this.getswipelist();
		},
		components:{silder,inputnumber}
	}
</script>

<style scoped>
	.silder{
		border:1px solid rgba(0,0,0,0.4);
	}
</style>